from pdfmine import extract_images
from img2pdf import jpgs2pdf

jpgs2pdf(extract_images('test.pdf'), 'output.pdf')
